package com.sec.bnjey.global;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

public class RbPreference {

	private final String PREF_NAME = "com.rabiaband.callerinfo";

	/*
	 * Define Applicaiton Preference String
	 */

	public final static String PREF_INTRO_USER_AGREEMENT = "PREF_USER_AGREEMENT";
	public final static String PREF_INTRO_REGISTER_CARINF1 = "PREF_REGISTER_CARINF1";
	public final static String PREF_INTRO_REGISTER_CARINF2 = "PREF_REGISTER_CARINF2";


	// sn
	public final static String PREF_SN = "PREF_SN";
	public final static String PREF_PHONE = "PREF_PHONE";

	// setting
	public final static String PREF_SETTING_COUNTRY = "PREF_SETTING_COUNTRY";
	public final static String PREF_SETTING_MAKER = "PREF_SETTING_MAKER";
	public final static String PREF_SETTING_CARNAME = "PREF_SETTING_CARNAME";
	public final static String PREF_SETTING_CC = "PREF_SETTING_CC";
	public final static String PREF_SETTING_COUNTRY_POSITION = "PREF_SETTING_COUNTRY_POSITION";
	public final static String PREF_SETTING_MAKER_POSITION = "PREF_SETTING_MAKER_POSITION";
	public final static String PREF_SETTING_CARNAME_POSITION = "PREF_SETTING_CARNAME_POSITION";
	public final static String PREF_SETTING_CC_POSITION = "PREF_SETTING_CC_POSITION";
	// setting / blackbox save path
	public static final String PREF_SETTING_BLACKBOX_PATH = "PREF_SETTING_BLACKBOX_PATH";

	// FW update time
	public static final String PREF_FIRMWARE_UPDATE_TIME = "PREF_FIRMWARE_UPDATE_TIME";

	public final static String PREF_RUN_WITHOUT_OBD = "PREF_RUN_WITHOUT_OBD";

	static Context mContext;

	public RbPreference(Context c) {
		mContext = c;
	}

	public void update(String key, String value) {
		SharedPreferences pref = mContext.getSharedPreferences(PREF_NAME,
				Activity.MODE_PRIVATE);
		SharedPreferences.Editor editor = pref.edit();

		editor.putString(key, value);
		editor.commit();
	}

	public void update(String key, boolean value) {
		SharedPreferences pref = mContext.getSharedPreferences(PREF_NAME,
				Activity.MODE_PRIVATE);
		SharedPreferences.Editor editor = pref.edit();

		editor.putBoolean(key, value);
		editor.commit();
	}

	public void update(String key, int value) {
		SharedPreferences pref = mContext.getSharedPreferences(PREF_NAME,
				Activity.MODE_PRIVATE);
		SharedPreferences.Editor editor = pref.edit();

		editor.putInt(key, value);
		editor.commit();
	}

	public String getValue(String key, String dftValue) {
		SharedPreferences pref = mContext.getSharedPreferences(PREF_NAME,
				Activity.MODE_PRIVATE);

		try {
			return pref.getString(key, dftValue);
		} catch (Exception e) {
			return dftValue;
		}

	}

	public int getValue(String key, int dftValue) {
		SharedPreferences pref = mContext.getSharedPreferences(PREF_NAME,
				Activity.MODE_PRIVATE);

		try {
			return pref.getInt(key, dftValue);
		} catch (Exception e) {
			e.printStackTrace();
			return dftValue;
		}

	}

	public boolean getValue(String key, boolean dftValue) {
		SharedPreferences pref = mContext.getSharedPreferences(PREF_NAME,
				Activity.MODE_PRIVATE);

		try {
			return pref.getBoolean(key, dftValue);
		} catch (Exception e) {
			e.printStackTrace();
			return dftValue;
		}
	}
}
